use std::cell::RefCell;
use std::rc::Rc;
use crate::heap::vm_heap::VMHeap;
use crate::vm_thread::{VMFrame, VMThread};
use crate::vm_val::{FALSE, VMValEnum};

pub fn java_lang_Class_getPrimitiveClass(frame: Rc<RefCell<VMFrame>>, thread: &VMThread) {
    let ro_frame = frame.borrow();
    let mut rw_local_vars = ro_frame.local_vars.borrow_mut();
    let jstr_class_name = rw_local_vars.get(&0).unwrap();

    let jclass_name = VMHeap::convert_jstring2rstring(jstr_class_name.clone());

    let mut rw_class_loader = thread.vm.class_loader.borrow_mut();

    let jclass = rw_class_loader.load_class(&jclass_name).unwrap();
    let class = rw_class_loader.load_class(&"java/lang/Class".to_string()).unwrap();

    let result = VMHeap::new_class_object(class.clone(), Some(jclass.clone()));

    ro_frame.operand_stack.borrow_mut().push(result.unwrap());
}


pub fn java_lang_Class_registerNatives(frame: Rc<RefCell<VMFrame>>, thread: &VMThread) {}


pub fn java_lang_Class_desiredAssertionStatus0(frame: Rc<RefCell<VMFrame>>, thread: &VMThread) {
    let ro_frame = frame.borrow();
    ro_frame.operand_stack.borrow_mut().push(VMValEnum::VMValBoolean { val: FALSE });
}